< previous page page_90 next page >

Page 90
EXERCISE
Adding a Form_Load() Event Procedure
1. Open the frmEmployee form.
2. Double-click the form.
3. Type in the following code:
Private Sub Form_Load ()
frmEmployee.Top = 1000
frmEmployee.Left = 500
End Sub
analysis.gifThe Form_Load() event is used to initialize the form to a good start state. Setting Top and Left will move the form to a certain location on the screen. You can set other properties within this event as well.
In this example, you actually change the value of the properties at runtime instead of design time by using the properties window. Try changing the value of these properties to see how the form responds.

How Do You Use Events?
Events are used to run some code that will perform a process based on some user action. An example might be changing the properties of a control, making a form close, closing your entire application, retrieving information from a database, or even displaying a graphic. To cause any of these things to happen, you simply write code that responds to a user action.
Changing Properties at Runtime
As shown earlier, properties can be changed at runtime by using the name of the control and the name of the property in your source code. A dot (.) operator is used to separate the name of the form or control from the property you want to change.
Here are some examples:
9f31265bb40b592b1929e18a47ab28e5.gif
Form.Caption = "My First Application"
Me.Top = 1000
lblLabel.Caption = "Enter First Name"
txtFirst.Text = "Bill"

 
< previous page page_90 next page >

If you like this book, buy it!